package com.erification.web.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.erification.web.dao.EmailDao;
import com.erification.web.model.Email;
import com.erification.web.service.EmailService;
@Service("emailService")
public class EmailServiceImpl implements EmailService {
	@Resource
	private EmailDao emailDao;
	@Override
	public void saveEmail(Email email) {
		emailDao.save(email);
	}

	@Override
	public void modifyEmail(long id, Email email, String newEmail) {
		List<Email> list = emailDao.getAll(id);
		for (Email em : list){
			if(em.getEmail().equals(email.getEmail())){
				em.setEmail(newEmail);
				emailDao.update(em);
			}
		}
	}

	@Override
	public void deleteEmail(long id) {
		emailDao.delete(id);
	}

	@Override
	public List<Email> getAll(long user_id) {
		return emailDao.getAll(user_id);
	}

	@Override
	public Email get(long id) {
		return emailDao.getEmailById(id);
	}

}
